package com.springcloud.consulconsumer.controller;

import com.springcloud.consulconsumer.feign.MyFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class ConsumerController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @Autowired
    MyFeign myFeign;

    /**
     * 获取所有服务
     */
    @GetMapping("/services")
    public Object services() {
        return discoveryClient.getInstances("consul-provider");
    }

    @GetMapping(value = "/hi")
    public String sayHi(String name){
        return myFeign.hi(name);
    }

    @Value("${osc.name}")
    private String name;

    @GetMapping(value = "/pull")
    public String pull(){
        return name;
    }
}
